<template>
	<view style="padding: 30rpx;">
		<u-subsection :list="list" :current="current" @change="sectionChange"></u-subsection>
		<view @click="toOrder(item.id)" v-for="(item,index) in dataList" :key="index" style="padding: 30rpx;background-color: #fff;border-radius: 16rpx;margin: 20rpx 0;">
			<view style="display: flex;align-items: center;justify-content: space-between;">
				<view style="font-size: 32rpx;">{{item.name}}</view> 	
				<!-- <view style="font-size: 24rpx;">使用中</view> -->
			</view>
			<view style="display: flex;align-items: center;justify-content: space-between;">
				<view>
					<view style="margin-top: 15rpx;">
						<text> 运输次数：</text>
						<text style="margin-left: 5rpx;color: #999;">{{item.num}} 次</text>
					</view>
					<view style="margin-top: 10rpx;">
						<text v-if="current==0"> 运输量：</text>
						<text v-if="current==1"> 接收量：</text>
						<text style="margin-left: 5rpx;color: #999;">{{item.total}} 吨</text>
					</view>
				</view>
				<view>
					<image :src="item.logo?item.logo:'../../../static/logo.png'" style="height: 150rpx;width: 150rpx;"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						name: '施工工地'
					},
					{
						name: '处置场所'
					}
				],
				current: 0,
				plateCode: '',
				type: 0, // 0.施工工地 1.处置场所
				dataList: []
			}
		},
		onLoad() {
			this.getDataList()
		},
		methods: {
			getDataList() {
				this.$u.get("/driver/vehicleRecords", {
					plateCode: this.plateCode,
					type: this.type
				}).then(res => {
					if (res.code == 200) {
						this.dataList = res.data
					}
				})
			},

			sectionChange(index) {
				this.current = index;
				if(index==0){
					this.type  = 0
				}else{
					this.type = 1
				}
				this.getDataList()
			},
			toOrder(id){
				uni.navigateTo({
					url:'/pages/index/ysjl/order-list/order-list?sitesId='+id+'&type='+this.type
				})
			}

		}
	}
</script>

<style>

</style>